@extends('layout.admin.master')
@section('content')

    <div class="card">
        <div class="card-header container-fluid">

            <h4 class="card-header-title">
                话题栏目
            </h4>
        </div>
        <div class="container-fluid">
            <ul class="nav nav-tabs mb-4">
                <li class="nav-item">
                    <a class="nav-link active" href="{{route('admin.column.index')}}">栏目列表</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{{route('admin.column.create')}}">添加栏目</a>
                </li>
            </ul>
        </div>
        <div class="container-fluid">

            <div class="card">
                <div class="card-body">

                    <div class="table-responsive text-center">
                        <table class="table">
                            <thead>

                            <tr>
                                <th scope="col">#</th>
                                <th scope="col">栏目名称</th>
                                <th scope="col">图标</th>
                                <th scope="col">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($columns as $column)
                            <tr>
                                <th scope="row">{{$column->id}}</th>
                                <td>{{$column->name}}</td>
                                <td><i class="{{$column->icon}}"></i></td>
                                <td>
                                    <a href="{{route('admin.column.edit',$column)}}" class="badge badge-soft-success">编辑</a>
                                    <a href="javascript:;" onclick="del(this)" class="badge badge-soft-danger">删除</a>
                                    <form action="{{route('admin.column.destroy',$column)}} " method="post">
                                        @csrf @method('DELETE')
                                    </form>
                                </td>
                            </tr>
                            @endforeach

                            </tbody>
                        </table>
                    </div>

                </div>
            </div>
        </div>

        </div>


@endsection
@push('js')
    <script>
        function del(obj) {
            require(['https://cdn.bootcss.com/sweetalert/2.1.0/sweetalert.min.js'],function (swal) {
                swal({
                    text: "确定删除吗?",
                    // buttons: ["取消", '确定'],
                    buttons: {
                        cancel: "取消",
                        defeat: '确定',
                    },
                }).then((value) => {
                    switch (value) {
                        case "defeat":
                            $(obj).next('form').trigger('submit');
                            break;
                    }
                });
            })
        }
    </script>
    @endpush
